package dfa;

import fa.FARule;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Arrays;
import java.util.List;

/**
 * @author haoly
 * @title DFARulebookTest
 * @date 2025/4/16 11:44
 * @description DFARulebookTest
 */
public class DFARulebookTest {
    @Test
    void testNextState() {
        List<FARule<Integer>> rules = Arrays.asList(
                new FARule<>(1, 'a', 2),
                new FARule<>(1, 'b', 1),
                new FARule<>(2, 'a', 2),
                new FARule<>(2, 'b', 3),
                new FARule<>(3, 'a', 3),
                new FARule<>(3, 'b', 3)
        );
        DFARulebook<Integer> rulebook = new DFARulebook<>(rules);

        assertEquals(2, rulebook.nextState(1, 'a'));
        assertEquals(1, rulebook.nextState(1, 'b'));
        assertEquals(2, rulebook.nextState(2, 'a'));
        assertEquals(3, rulebook.nextState(2, 'b'));
        assertEquals(3, rulebook.nextState(3, 'a'));
        assertEquals(3, rulebook.nextState(3, 'b'));
    }
}
